package com.bysc.joinservice.redis;

import com.bysc.joinservice.controller.JoinActivityController;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

@Component
public class MessageReceive {

    /**接收消息的方法*/
    public void receiveMessage(String message){
        System.out.println("----------收到消息了message："+message);
        if(!StringUtils.isEmpty(message)) {
            message = message.replaceAll("\"","");
            String[] split = StringUtils.split(message, ":");
            if (split == null || split.length == 2) {
                if ("-1".equals(split[1])) {
                    JoinActivityController.status.remove(split[0]);
                }else  {
                    JoinActivityController.status.put(split[0], split[1]);
                }
            }
        }
    }

}
